package com.moodswings.server;

import com.moodswings.server.model.Mood;
import com.moodswings.server.service.MoodService;
import flexjson.JSONSerializer;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


public class TableServlet extends HttpServlet {

	JSONSerializer serializer = new JSONSerializer();

	MoodService moodService;

	public TableServlet() {
		moodService = new MoodService();
	}

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List<Mood> moodList = moodService.findLastMoods(25);

		request.setAttribute("moodList", moodList);

		response.setContentType("text/html");

		RequestDispatcher requestDispatcher = request.getRequestDispatcher("table.jspf");
		requestDispatcher.forward(request, response);
	}

}
